package com.example.demo.game;

import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author CY
 * @date 2023/04/03 14:57
 **/
@Component
public class OnlineUserMapper {
    //表示这个yoghurt
    private ConcurrentHashMap<Integer, WebSocketSession> gameHall = new ConcurrentHashMap<Integer, WebSocketSession>();

    public void enterGameHall(Integer id, WebSocketSession session) {
        gameHall.put(id, session);
    }

    public void exitGameHall(Integer id) {
        gameHall.remove(id);
    }

    public WebSocketSession getGameHall(Integer id) {
        return gameHall.get(id);
    }

}
